<?php

function getItemHtml($image_height,$image_url,$image_link)
{
    $image_height = $image_height.'px';
    return "
<li class='item'>
    <a style='height:$image_height;background-image: url($image_url);' target='_blank'  $image_link class='image' ></a>
</li>
    ";
}

function getParam($paramName, $defaultValue)
{
    global $_MODULE;
    $value = $_MODULE[$paramName];
    if (empty($value)) return $defaultValue;
    return $value;
}

function myEcho($paramName, $defaultValue)
{
    echo getParam($paramName, $defaultValue);
}


?>

<div class='module dshop-um-wl-lb-12 module-thirdparty'
     style='margin-bottom:<? myEcho('bottom_margin','30'); ?>px; background-color:<? myEcho('bottom_color','#555555'); ?>;'>

    <div class='container m-sop-slide <?php myEcho('is_show_ring','')?>' >
        <div class='inner_container'>
            <ol class='slide-pics'>
                <?php
                $image_height_array = array();
                $arrayMap = array();
                $is_empty = true;

                for($i = 0; $i < getParam('image_num',2);$i++){
                    $image_url = getParam('image_url_'.$i,'');
                    if(empty($image_url)){
                        continue;
                    }

                    $is_empty = false;
                    $image_height = getParam('image_height_'.$i,400);
                    array_push($image_height_array,$image_height);
                    echo getItemHtml(
                        $image_height,
                        $image_url,
                        getHref('image_link_'.$i));
                }

                $button_top = $is_empty ? '200px': (max($image_height_array) / 2).'px';
                if($is_empty){
                    echo getItemHtml(
                        '400',
                        '../../assets/images/10.jpg',
                        'href="#"');
                    echo getItemHtml(
                        '400',
                        'assets/images/9602.jpg',
                        'href="#"');
                }

                ?>
            </ol>
        </div>

        <?php
        if(getParam('is_show_arrows','show') == 'show'){
            $arrow_type = getParam('arrows_type','');
            $blue_arrows_next = $arrow_type.'_next';
            $blue_arrows_prev = $arrow_type.'_prev';
            echo "
                    <a style='top:$button_top;' class='prev-btn $blue_arrows_prev'></a>
                    <a style='top:$button_top;' class='next-btn $blue_arrows_next'></a>
                ";
        }
        ?>


    </div>

</div>
